import Vue from "vue";
import App from "./App.vue";
//导入typenav组件
import TypeNav from "@/components/TypeNav";
import SliderLoop from "@/components/SliderLoop";
import Pagination from '@/components/Pagination'
//导入路由器
import router from "@/router";
//导入store
import store from "@/store";
//导入执行模拟后端服务器接口
import "@/mock/mockServer";
//引入swiper的css，只要引入一次，哪里都能使用
import 'swiper/css/swiper.css'
//引入api函数，API是一个对象
import * as API from '@/api'

//ele-ui完整引入
// import ElementUI from 'element-ui';
//import 'element-ui/lib/theme-chalk/index.css';
//注册组件
// Vue.use(ElementUI);

//按需引入
import { Button ,MessageBox,Message, } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.component(Button.name,Button);
Vue.prototype.$message = Message;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;


//图片懒加载
import VueLazyload  from 'vue-lazyload'
import loadimage from '@/assets/images/loading.gif'
Vue.use(VueLazyload,{
  loading: loadimage,
});

//vee-validate@2.2.15  引入
import '@/plugins/validate'

//测试接口方法
// import '@/api/index'

//全局注册
//typeNav本质是配置项，Vue.component方法(组件名，组件配置项)，内部调用Vue.extend生成组件。
Vue.component(TypeNav.name, TypeNav);
Vue.component(SliderLoop.name, SliderLoop);
Vue.component('Pagination',Pagination);

Vue.config.productionTip = false;

new Vue({
  beforeCreate() {
    //建全局事件总线:1、Vue.prototype所有vc可以访问到2、vm上有$on和$bus,也更稳定
    Vue.prototype.$bus = this;
    // console.log(Vue.prototype);
    //引入全局API：接口函数
    Vue.prototype.$API = API;
  },
  render: (h) => h(App),
  router,
  store,
}).$mount("#app");
